package com.tom.model;

import java.util.List;

/**
 * @author zx
 * @date 2025年02月14日 10:57
 */
public class Page<T> {
    private long current;
    private long size;
    private long total;
    private List<T> records;
    private long pages;


    public long getCurrent() {
        return current;
    }

    public Page<T> setCurrent(long current) {
        this.current = current;
        return this;
    }

    public long getSize() {
        return size;
    }

    public Page<T> setSize(long size) {
        this.size = size;
        return this;
    }

    public long getTotal() {
        return total;
    }

    public Page<T> setTotal(long total) {
        this.total = total;
        return this;
    }

    public List<T> getRecords() {
        return records;
    }

    public Page<T> setRecords(List<T> records) {
        this.records = records;
        return this;
    }

    public long getPages() {
        if (this.getSize() == 0) {
            return 0;
        }
        long pages = this.getTotal() / this.getSize();
        if (this.getTotal() % this.getSize() != 0) {
            pages++;
        }
        return pages;
    }

    public Page<T> setPages(long pages) {
        return this;
    }

    @Override
    public String toString() {
        return "Page{" +
                "current=" + current +
                ", size=" + size +
                ", total=" + total +
                ", records=" + records +
                ", pages=" + getPages() +
                '}';
    }
}
